export function getMusicTime(second) { // 根据音乐秒数计算时间
    let time = '00:00';
    let m = Math.floor(second / 60)
    let s = Math.floor(second % 60)
    // parseInt(t[0], 10) * 60 + parseFloat(t[1])
    if (m < 10) {
        time = '0' + m;
    } else {
        time = m;
    }
    if (s < 10) {
        time += ':0' + s;
    } else {
        time += ':' + s;
    }
    return time
}
//时间戳转换方法    date:时间戳数字
export function formatDate(timestamp) {
    let date = new Date(timestamp);
    let YY = date.getFullYear() + '-';
    let MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
    // let hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    // let mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    // let ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
    return YY + MM + DD;
}

/**
 * 数组去重
 * @param source
 * @param target []
 * @returns {*}
 */
export function mergeArrar(source,target){
    if (target ==null || target.length === 0) {
        return source
    }
    if (source == null) {
        source = new Array();
    }
    // 将新添加的和原有的进行合并去重
    source =  source.concat(target)
    let map = new Map();
    for (let item of source) {
        if (!map.has(item.id)){
            map.set(item.id,item)
        }
    }
    let arr = [...map.values()]
    return arr
}
